#include<stdio.h>
#include<string.h>
#include<math.h>
int yan(int n,int x)
{
	if(n<x)
	return 0;
	else
	return n/x+yan(n/x+n%x,x);
}
int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	printf("%d",n+yan(n,x));
	return 0;
}